﻿using System;
using UnityEngine;

// Token: 0x020001D9 RID: 473
public class CardCapture : MonoBehaviour
{
	// Token: 0x06000CA2 RID: 3234 RVA: 0x0004B81C File Offset: 0x00049A1C
	private void OnDestroy()
	{
		if (this.capCamera == null)
		{
			return;
		}
		RenderTexture targetTexture = this.capCamera.targetTexture;
		this.capCamera.targetTexture = null;
		UnityEngine.Object.Destroy(targetTexture);
	}

	// Token: 0x06000CA3 RID: 3235 RVA: 0x0004B85C File Offset: 0x00049A5C
	public Texture2D Capture()
	{
		int num = this.saveWidth * this.superSize;
		int num2 = this.saveHeight * this.superSize;
		RenderTexture temporary = RenderTexture.GetTemporary(num, num2, 24);
		this.capCamera.targetTexture = temporary;
		this.capCamera.Render();
		RenderTexture.active = temporary;
		Texture2D texture2D = new Texture2D(num, num2, TextureFormat.RGB24, false);
		texture2D.ReadPixels(new Rect(0f, 0f, (float)num, (float)num2), 0, 0);
		texture2D.Apply();
		TextureScale.Bilinear(texture2D, this.saveWidth, this.saveHeight);
		this.capCamera.targetTexture = null;
		RenderTexture.ReleaseTemporary(temporary);
		return texture2D;
	}

	// Token: 0x04000CCC RID: 3276
	[SerializeField]
	private Camera capCamera;

	// Token: 0x04000CCD RID: 3277
	[SerializeField]
	private int superSize = 2;

	// Token: 0x04000CCE RID: 3278
	[SerializeField]
	private int saveWidth = 252;

	// Token: 0x04000CCF RID: 3279
	[SerializeField]
	private int saveHeight = 352;
}
